- Customizar apariencia
- HTML & CSS
Extensiones a Shiny (mediante paquetes)
Compartir las apps por internet
MapEs (una app desarrollada por FISABIO - DG Salud Pública)
07 de Junio, 2017
Extensiones a Shiny (mediante paquetes)
Compartir las apps por internet
MapEs (una app desarrollada por FISABIO - DG Salud Pública)
ui <- fluidPage(
HTML("<h1>Título hecho con HTML</h1>")
)
# Definición del server
server <- function(input, output) {}
# App completa con los componentes ui y server
shinyApp(ui, server)
ui <- fluidPage(
tags$h1("Título hecho con R")
)
# Definición del server
server <- function(input, output) {}
# App completa con los componentes ui y server
shinyApp(ui, server)
tags: h1() - h6()
Cabeceras
ui <- fluidPage(
h1("Tamaño 1"),
h2("Tamaño 2"),
h3("Tamaño 3"),
h4("Tamaño 4"),
h5("Tamaño 5"),
h6("Tamaño 6")
)
# Definición del server
server <- function(input, output) {}
# App completa con los componentes ui y server
shinyApp(ui, server)
tags: hr()
Línea horizontal
ui <- fluidPage(
h3("texto"),
hr(),
h3("texto")
)
# Definición del server
server <- function(input, output) {}
# App completa con los componentes ui y server
shinyApp(ui, server)
tags: "Texto"
Texto normal. El texto plano sin modificadores no necesita tags.
ui <- fluidPage(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua."
)
# Definición del server
server <- function(input, output) {}
# App completa con los componentes ui y server
shinyApp(ui, server)
tags: br()
Salto de línea
ui <- fluidPage(
"Texto 1",
br(),
"Texto 2"
)
# Definición del server
server <- function(input, output) {}
# App completa con los componentes ui y server
shinyApp(ui, server)
tags: p()
Párrafo
ui <- fluidPage(
p("Párrafo 1"),
p("Párrafo 2")
)
# Definición del server
server <- function(input, output) {}
# App completa con los componentes ui y server
shinyApp(ui, server)
tags: em()
Itálica
ui <- fluidPage(
em("itálica")
)
# Definición del server
server <- function(input, output) {}
# App completa con los componentes ui y server
shinyApp(ui, server)
tags: strong()
Negrita
ui <- fluidPage(
strong("negrita")
)
# Definición del server
server <- function(input, output) {}
# App completa con los componentes ui y server
shinyApp(ui, server)
tags: code()
Texto monoespaciado
ui <- fluidPage(
code("código")
)
# Definición del server
server <- function(input, output) {}
# App completa con los componentes ui y server
shinyApp(ui, server)
Los tags se pueden anidar unos dentro de otros.
ui <- fluidPage(
p("Lorem ipsum dolor sit amet, ", strong("consectetur"), " adipiscing elit, ", em("sed eiusmod tempor incidunt ut labore et dolore magna aliqua."))
)
# Definición del server
server <- function(input, output) {}
# App completa con los componentes ui y server
shinyApp(ui, server)
Las hojas de estilo en cascada (CSS) son un marco para personalizar la apariencia de elementos en una página web.
ui <- fluidPage(
theme = "bootstrap.css",
sidebarLayout(
sidebarPanel(),
mainPanel()
)
)
# Definición del server
server <- function(input, output) {}
# App completa con los componentes ui y server
shinyApp(ui, server)
ui <- fluidPage(
includeCSS("bootstrap.css"),
sidebarLayout(
sidebarPanel(),
mainPanel()
)
)
# Definición del server
server <- function(input, output) {}
# App completa con los componentes ui y server
shinyApp(ui, server)Extensiones de formato
Extensiones para cálculos/gráficos interactivos
## app.R ##
library(shinythemes)
shinyApp(
ui = fluidPage(theme = shinytheme("united"),
...
),
server = function(input, output) { }
)
85 widgets registrados actualmente (selección):
library(leaflet) leaflet() %>% addTiles() %>% addMarkers(lng=-0.3531, lat=39.4815, popup="FISABIO")
library(ggplot2, plotly) p <- ggplot(data = diamonds, aes(x = cut, fill = clarity)) + geom_bar(position = "dodge") ggplotly(p)
library(dygraphs)
lungDeaths <- cbind(ldeaths, mdeaths, fdeaths)
dygraph(lungDeaths, main = "Deaths from Lung Disease (UK)") %>%
dyHighlight(highlightCircleSize = 5,
highlightSeriesBackgroundAlpha = 0.2,
hideOnMouseOut = FALSE)
library(networkD3) data(MisLinks, MisNodes) forceNetwork(Links = MisLinks, Nodes = MisNodes, Source = "source", Target = "target", Value = "value", NodeID = "name", Group = "group", opacity = 0.4)
DT::datatable(iris, options = list(pageLength = 3, dom = "pt", language = list(url = '//cdn.datatables.net/plug-ins/1.10.11/i18n/Spanish.json')), rownames = FALSE, escape = FALSE)
library(d3heatmap) d3heatmap(mtcars, scale = "column", colors = "Spectral")
library(rgl, rglwidget, htmltools)
theta <- seq(0, 6*pi, len=100)
xyz <- cbind(sin(theta), cos(theta), theta)
lineid <- plot3d(xyz, type="l", alpha = 1:0, lwd = 5, col = "blue")["data"]
browsable(tagList(
rglwidget(elementId = "example", width = 500, height = 400,
controllers = "player"),
playwidget("example",
ageControl(births = theta, ages = c(0, 0, 1),
objids = lineid, alpha = c(0, 1, 0)),
start = 1, stop = 6*pi, step = 0.1,
rate = 6,elementId = "player")))
de forma local, con alguien que tiene R en su ordenador.
de forma global, con todo el mundo (sin necesidad de tener R).
runUrl( "<link a la web>")
runGitHub( "<nombre de tu repositorio>", "<tu nombre de usuario>")
Alojar tu app en tu repositorio libre de GitHub, manteniendo tu anonimato con Gist
runGist("código gist")
RStudio Team. 2016. RStudio: Integrated Development Environment for R. Boston, MA: RStudio, Inc. http://www.rstudio.com/.
Wickham, H. 2015. Advanced R. Boca Raton, FL: CRC.